package com.x.chalk.controller;

import com.x.chalk.config.SystemConfig;
import com.x.chalk.dto.CommentDto;
import com.x.chalk.entity.Comment;
import com.x.chalk.service.intf.CommentService;
import com.x.chalk.vo.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * @Author FSir
 * @create 2022/10/5 16:43
 */
@RestController
@RequestMapping("/api/comment/")
@Api(tags = "圈子评论相关操作")
@CrossOrigin
public class CommentController {
    @Autowired
    private CommentService service;

    /**
     * 添加评论
     * @param dto
     * @return
     */
    @PostMapping("add.do")
    @ApiOperation(value = "添加评论")
    public R add(@RequestBody CommentDto dto, HttpServletRequest request){
      return service.add(dto,request.getHeader(SystemConfig.HEADER_TOKEN));

    }
    /**
     * 回复评论
     * @param dto
     * @return
     */
    @PostMapping("reply.do")
    @ApiOperation(value = "回复评论")
    public R reply(@RequestBody CommentDto dto, HttpServletRequest request){
        return service.reply(dto,request.getHeader(SystemConfig.HEADER_TOKEN));

    }

}
